package logic

import (
	"context"
	"shell/houserpc/houserpc"

	"shell/api/internal/svc"
	"shell/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PreUpdatesLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPreUpdatesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PreUpdatesLogic {
	return &PreUpdatesLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PreUpdatesLogic) PreUpdates(req *types.PreUpdatesRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	updates, err := l.svcCtx.HouseRpc.PreUpdates(l.ctx, &houserpc.PreUpdatesRequest{PreId: req.PreId})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "预约取消成功",
		Data:    updates,
	}, nil
}
